
import React from "react"
import Appcss1 from "./css/Reg.module.css"
import fanh from '../../assets/icons/返回箭头.png'
import nicheng from '../../assets/icons/昵称.png'
import { List,  InputItem} from 'antd-mobile';
import { Toast, WhiteSpace, WingBlank, Button } from 'antd-mobile';
// import { createForm } from 'rc-form';
// import Logo from '../assets/icons/logo.png'
class Password extends React.Component {
    constructor(){
        super()
        this.state={

            nickname:"",
          
            password:"",

        }
    }
    ipt1(e){
        // var uPattern = /^[a-zA-Z0-9_-]{4,16}$/;
        // if(!uPattern.test(e.target.value)){
        this.setState({
            password:e.target.value,
        })
    // }else{
    //         alert(1111)
    //     }

    }
    ipt2(e){
        this.setState({
            nickname:e.target.value,
        })
    }
    componentWillMount(){
        console.log(this.props.location.phone+"!!!!!!!!!!!!!!")
        console.log(this.props.location.captcha+"!!!!!!!!!!!!!!")
        
    }
    send(){
        console.log(this.state.password+"!!!!!!!!!!!!!!")
        console.log(this.state.nickname+"!!!!!!!!!!!!!!")
        fetch(`http://106.12.10.151:3000/register/cellphone?phone=${this.props.location.phone}&password=${this.state.password}&captcha=${this.props.location.captcha}&nickname=${this.props.location.nickname+"1zhkx2"}`,{  credentials:'include'})
        .then(body=>body.json())
        .then(res=>{
            if(res.code==200){
               console.log(res);
                Toast.loading('success...', 1, () => {
                    this.props.history.push({pathname:"/BasicInputExample"})
                  });
               
            }
            else{
                Toast.fail('输入错误', 1); 
            }
        })
        // .catch(
        //     Toast.fail('网络错误', 1)
        // )
    }
    fanhu(){
        this.props.history.push({pathname:"/login"})
    }
    render(){
        return(
           
        <div className={Appcss1.cel_log2}>
             {/* <div className={Appcss1.cel_zc}>
                <span id={Appcss1.cel_fh} onClick={this.fanhu.bind(this)}><img src={fanh} width='100%' height='100%' alt=''/></span>
                <span id={Appcss1.cel_reg}>手机号注册</span>
                
            </div> */}
            {/* <div >
            <h5>请输入密码</h5>
             </div> */}
              <div className={Appcss1.cel_zc}>
                <span id={Appcss1.cel_fh} onClick={this.fanhu.bind(this)}><img src={fanh} width='100%' height='100%' alt=''/></span>
                <span id={Appcss1.cel_reg}>修改密码</span>
                
            </div>
            <div className={Appcss1.nicheng}>
            <img src={nicheng} width='100%' height='100%' alt=''/>
             </div>
             <div >
               <input type="text" className={Appcss1.cel_pa} placeholder="请输入昵称"  onBlur={this.ipt2.bind(this)} ></input>
             </div>
             <div >
               <input type="password" className={Appcss1.cel_pa} placeholder="请输入密码"  onBlur={this.ipt1.bind(this)}></input>
             </div>
             <button className={Appcss1.cel_re} onClick={this.send.bind(this)}>开启云音乐</button><br/>
            
			{/* <button className={Appcss1.cel_re} onClick={this.send.bind(this)}>下一步</button><br/> */}
            {/* <span className={Appcss.cel_qtdl}>&lt;其他登录方式</span> */}
		</div>
    
        )
    }



}
// const Cell_login1 = createForm()(Cell_login);
export default Password